<template>
  <div class="container">  
    <h1>{{countDown}}</h1>
  </div>
</template>

<script>
export default {
  data() {
    return {
      countDown:'',
    };
  },
  created() {
   setInterval(this.time,1000);
  },
  methods: {
    time(){
        var nowTime = new Date(),
          wyTime = new Date("2022-05-01 0:0:0:");
        var time = wyTime - nowTime;
        var day = Math.floor(time / 1000 / 60 / 60 / 24),
            hours = Math.floor((time / 1000 / 60 / 60) % 24),
           minute = Math.floor((time / 1000 / 60) % 60),
           second = Math.floor((time / 1000) % 60);
        this.countDown ="距离五一还有" +day + "天" + hours +"小时" + minute + "分钟" + second + "秒";
    //    this.countDown = str;  
    }
  },
};
</script>

<style scoped>
</style>
